<template>
  <div class="existing wd1200">
    <v-title color="#FF8C1A" background-color="#FFF3E8" title="创新企业" class="title" />
    <el-row class="list-box" :gutter="20">
      <el-col v-for="(item,index) in list" :key="item.title" :span="12">
        <div class="classify" @click="toUrl(item)">
          <div>
            <img :src="item.icon" alt="">
            <span>{{ item.title }}</span>
          </div>
          <div>
            <span v-loading="loading" class="color-o" style="text-align: end;display: inline-block;min-width: 80px">{{ counts[index] }}家</span>
            <img :style="{'visibility': item.url ? '' : 'hidden'}" src="../../../../assets/images/busNeighbors/r.png" alt="" class="right-icon">
          </div>
        </div>
      </el-col>
    </el-row>
  </div>
</template>
<script>
import vTitle from '@/components/busNeighbors/title'
import { company_base_live_count, annual_report_social_security_count_100, company_in_camp_count } from '@/api/busNeighbors'
export default {
  name: 'Existing',
  components: {
    vTitle
  },
  data() {
    return {
      list: [{
        icon: require('@/assets/images/busNeighbors/1.png'),
        title: '存活三年以上企业',
        num: '2000家',
        api: 'company_base_live_list',
        url: '/bus-neighbors/list',
        searchApi: [{
          api: 'company_base_live_chart',
          params: {
            endDate: this.$dayjs().endOf('month').format('YYYY-MM-DD'),
            lyComType: 5,
            lyId: Number(this.$route.query.id)
          }
        }, {
          api: 'company_base_live_year_count',
          params: {
            endDate: this.$dayjs().endOf('month').format('YYYY-MM-DD'),
            lyComType: 5,
            lyId: Number(this.$route.query.id)
          }
        }],
        params: {
          endDate: this.$dayjs().endOf('month').format('YYYY-MM-DD'),
          lyId: Number(this.$route.query.id),
          pageNumber: 1,
          pageSize: 10
        },
        loading: true
      },
      {
        icon: require('@/assets/images/busNeighbors/2.png'),
        title: '参保人数100人以上企业数',
        num: '2000家',
        api: 'annual_report_social_security_count_100_list',
        url: '/bus-neighbors/list',
        searchApi: [{
          api: 'annual_report_social_security_chart_100',
          params: {
            establishDateEnd: this.$dayjs().endOf('month').format('YYYY-MM-DD'),
            lyComType: 5,
            lyId: Number(this.$route.query.id)
          }
        }, {
          api: 'annual_report_social_security_year_count_100',
          params: {
            establishDateEnd: this.$dayjs().endOf('month').format('YYYY-MM-DD'),
            lyComType: 5,
            lyId: Number(this.$route.query.id)
          }
        }],
        params: {
          establishDateEnd: this.$dayjs().endOf('month').format('YYYY-MM-DD'),
          lyComType: 5,
          lyId: Number(this.$route.query.id),
          pageNumber: 1,
          pageSize: 10
        }
      },
      {
        icon: require('@/assets/images/busNeighbors/3.png'),
        title: '注册资本2000万以上企业数',
        num: '2000家',
        api: 'company_base_list_by_type',
        url: '/bus-neighbors/list',
        searchApi: [{
          api: 'company_base_list_by_capital_count',
          params: {
            companyMajorType: 3,
            establishDate: this.$dayjs().endOf('month').format('YYYY-MM-DD'),
            lyComType: 5,
            lyId: Number(this.$route.query.id),
            minCapitalNum: 2000
          }
        }, {
          api: 'company_base_list_by_year_count',
          params: {
            companyMajorType: 3,
            establishDate: this.$dayjs().endOf('month').format('YYYY-MM-DD'),
            lyComType: 1,
            lyId: Number(this.$route.query.id),
            minCapitalNum: 2000
          }
        }],
        params: {
          companyMajorType: 3,
          endDate: this.$dayjs().endOf('month').format('YYYY-MM-DD'),
          lyComType: 5,
          lyId: Number(this.$route.query.id),
          minCapitalNum: 2000,
          pageNumber: 1,
          pageSize: 10,
          startDate: this.$dayjs().startOf('month').format('YYYY-MM-DD')
        }
      },
      // {
      //   icon: require('@/assets/images/busNeighbors/4.png'),
      //   title: '走访企业数',
      //   num: '2000家',
      //   api: 'company_base_list_by_type',
      //   url: '',
      //   searchApi: [{
      //     api: 'company_base_list_by_capital_count',
      //     params: {
      //       comType: 2,
      //       companyMajorType: 3,
      //       establishDate: this.$dayjs().endOf('month').format('YYYY-MM-DD'),
      //       lyComType: 5,
      //       lyId: Number(this.$route.query.id)
      //     }
      //   }, {
      //     api: 'company_base_list_by_year_count',
      //     params: {
      //       comType: 2,
      //       companyMajorType: 3,
      //       establishDate: this.$dayjs().endOf('month').format('YYYY-MM-DD'),
      //       lyComType: 5,
      //       lyId: Number(this.$route.query.id)
      //     }
      //   }],
      //   params: {
      //     comType: 2,
      //     companyMajorType: 3,
      //     endDate: this.$dayjs().endOf('month').format('YYYY-MM-DD'),
      //     lyComType: 5,
      //     lyId: Number(this.$route.query.id),
      //     pageNumber: 1,
      //     pageSize: 10
      //   }
      // },
      // {
      //   icon: require('@/assets/images/busNeighbors/5.png'),
      //   title: '扶持企业数',
      //   num: '2000家',
      //   api: 'company_base_list_by_type',
      //   url: '',
      //   searchApi: [{
      //     api: 'company_base_list_by_capital_count',
      //     params: {
      //       comType: 4,
      //       companyMajorType: 3,
      //       establishDate: this.$dayjs().endOf('month').format('YYYY-MM-DD'),
      //       lyComType: 5,
      //       lyId: Number(this.$route.query.id)
      //     }
      //   }, {
      //     api: 'company_base_list_by_year_count',
      //     params: {
      //       comType: 4,
      //       companyMajorType: 3,
      //       establishDate: this.$dayjs().endOf('month').format('YYYY-MM-DD'),
      //       lyComType: 5,
      //       lyId: Number(this.$route.query.id)
      //     }
      //   }],
      //   params: {
      //     comType: 4,
      //     companyMajorType: 3,
      //     endDate: this.$dayjs().endOf('month').format('YYYY-MM-DD'),
      //     lyComType: 5,
      //     lyId: Number(this.$route.query.id),
      //     pageNumber: 1,
      //     pageSize: 10
      //   }
      // },
      // {
      //   icon: require('@/assets/images/busNeighbors/6.png'),
      //   title: '关注企业数',
      //   num: '2000家',
      //   api: 'company_base_list_by_type',
      //   url: '',
      //   searchApi: [{
      //     api: 'company_base_list_by_capital_count',
      //     params: {
      //       comType: 3,
      //       companyMajorType: 3,
      //       establishDate: this.$dayjs().endOf('month').format('YYYY-MM-DD'),
      //       lyComType: 5,
      //       lyId: Number(this.$route.query.id)
      //     }
      //   }, {
      //     api: 'company_base_list_by_year_count',
      //     params: {
      //       comType: 3,
      //       companyMajorType: 3,
      //       establishDate: this.$dayjs().endOf('month').format('YYYY-MM-DD'),
      //       lyComType: 5,
      //       lyId: Number(this.$route.query.id)
      //     }
      //   }],
      //   params: {
      //     comType: 3,
      //     companyMajorType: 3,
      //     endDate: this.$dayjs().endOf('month').format('YYYY-MM-DD'),
      //     lyComType: 5,
      //     lyId: Number(this.$route.query.id),
      //     pageNumber: 1,
      //     pageSize: 10
      //   }
      // },
      // {
      //   icon: require('@/assets/images/busNeighbors/7.png'),
      //   title: '挂点企业数',
      //   num: '2000家',
      //   api: 'company_base_list_by_type',
      //   url: '',
      //   searchApi: [{
      //     api: 'company_base_list_by_capital_count',
      //     params: {
      //       comType: 5,
      //       companyMajorType: 3,
      //       establishDate: this.$dayjs().endOf('month').format('YYYY-MM-DD'),
      //       lyComType: 5,
      //       lyId: Number(this.$route.query.id)
      //     }
      //   }, {
      //     api: 'company_base_list_by_year_count',
      //     params: {
      //       comType: 5,
      //       companyMajorType: 3,
      //       establishDate: this.$dayjs().endOf('month').format('YYYY-MM-DD'),
      //       lyComType: 5,
      //       lyId: Number(this.$route.query.id)
      //     }
      //   }],
      //   params: {
      //     comType: 5,
      //     companyMajorType: 3,
      //     endDate: this.$dayjs().endOf('month').format('YYYY-MM-DD'),
      //     lyComType: 5,
      //     lyId: Number(this.$route.query.id),
      //     pageNumber: 1,
      //     pageSize: 10
      //   }
      // },
      // {
      //   icon: require('@/assets/images/busNeighbors/8.png'),
      //   title: '协会企业数',
      //   num: '2000家',
      //   api: 'company_base_list_by_type',
      //   url: '',
      //   searchApi: [{
      //     api: 'company_base_list_by_capital_count',
      //     params: {
      //       comType: 6,
      //       companyMajorType: 3,
      //       establishDate: this.$dayjs().endOf('month').format('YYYY-MM-DD'),
      //       lyComType: 5,
      //       lyId: Number(this.$route.query.id)
      //     }
      //   }, {
      //     api: 'company_base_list_by_year_count',
      //     params: {
      //       comType: 6,
      //       companyMajorType: 3,
      //       establishDate: this.$dayjs().endOf('month').format('YYYY-MM-DD'),
      //       lyComType: 5,
      //       lyId: Number(this.$route.query.id)
      //     }
      //   }],
      //   params: {
      //     comType: 6,
      //     companyMajorType: 3,
      //     endDate: this.$dayjs().endOf('month').format('YYYY-MM-DD'),
      //     lyComType: 5,
      //     lyId: Number(this.$route.query.id),
      //     pageNumber: 1,
      //     pageSize: 10
      //   }
      // }
      ],
      counts: [],
      loading: true
    }
  },
  async mounted() {
    Promise.all([
      await company_base_live_count({
        endDate: this.$dayjs().endOf('month').format('YYYY-MM-DD'),
        lyId: Number(this.$route.query.id)
      }),
      await annual_report_social_security_count_100({
        establishDateEnd: this.$dayjs().endOf('month').format('YYYY-MM-DD'),
        lyId: Number(this.$route.query.id)
      }),
      await company_in_camp_count({
        companyMajorType: 3,
        establishDate: this.$dayjs().endOf('month').format('YYYY-MM-DD'),
        lyComType: 5,
        lyId: Number(this.$route.query.id),
        minCapitalNum: 2000
      }),
      await company_in_camp_count({
        comType: 2,
        companyMajorType: 3,
        establishDate: this.$dayjs().endOf('month').format('YYYY-MM-DD'),
        lyComType: 5,
        lyId: Number(this.$route.query.id)
      }),
      await company_in_camp_count({
        comType: 4,
        companyMajorType: 3,
        establishDate: this.$dayjs().endOf('month').format('YYYY-MM-DD'),
        lyComType: 5,
        lyId: Number(this.$route.query.id)
      }),
      await company_in_camp_count({
        comType: 3,
        companyMajorType: 3,
        establishDate: this.$dayjs().endOf('month').format('YYYY-MM-DD'),
        lyComType: 5,
        lyId: Number(this.$route.query.id)
      }),
      await company_in_camp_count({
        comType: 5,
        companyMajorType: 3,
        establishDate: this.$dayjs().endOf('month').format('YYYY-MM-DD'),
        lyComType: 5,
        lyId: Number(this.$route.query.id)
      }),
      await company_in_camp_count({
        comType: 6,
        companyMajorType: 3,
        establishDate: this.$dayjs().endOf('month').format('YYYY-MM-DD'),
        lyComType: 5,
        lyId: Number(this.$route.query.id)
      })
    ]).then(res => {
      this.loading = false
      this.counts = res.map(item => item.data && (item.data.content[0].count || item.data.content[0].total || item.data.content[0].capitalNumTotal) || 0)
    })
  },
  methods: {
    toUrl(item) {
      this.$router.push({ path: item.url, query: { data: JSON.stringify(item), companyNames: this.$route.query.name }})
    }
  }
}
</script>
    <style lang="scss" scoped>
    .existing {
      .list-box{
        width: 100%;
        padding-left: 20px;
      }
      .title{
        margin: 0 20px 20px 20px;
        width: calc(100% - 40px);
      }
      .classify{
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 10px 0 10px 10px;
        background: #FFFFFF;
        border-radius: 6px 6px 6px 6px;
        border: 1px solid #E8EAEC;
        margin-bottom: 20px;
        .right-icon{
          width: 14px;
          height: 14px;
        }
        img{
          width: 24px;
          height: 24px;
          margin-right: 10px;
        }
        div{
          display: flex;
          align-items: center;
          font-size: 13px;
          color: #000000;
        }
        .color-o {
          color: #FF8C1A;
        }
      }
      .con{
        width: 100%;
        border: 1px solid #E8EAEC;
        margin-bottom: 20px;
        // height: 300px;
        .m-tit{
          padding-left: 26px;
          font-weight: 700;
          font-family: PingFang SC, PingFang SC;
        }
      }
    }
    </style>
